package com.towker.frame.controller.report;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.towker.core.page.PageModel;
import com.towker.core.page.PageNav;
import com.towker.frame.model.purchase.Suppliers;
import com.towker.frame.model.report.Warehouse;
import com.towker.frame.model.warehouse.GoodsAllocates;
import com.towker.frame.service.basicData.DepartmentsService;
import com.towker.frame.service.report.WarehouseService;
import com.towker.frame.service.warehouse.OutWarehouseService;
import com.towker.web.MyRequest;

//仓库报表
@Controller
@SuppressWarnings("unchecked")
@RequestMapping("/manage/report/warehouse")
public class WarehouseController {
	
	private WarehouseService warehouseService;
	private DepartmentsService departmentsService;//部门信息
	
	public void setWarehouseService(WarehouseService warehouseService)
	{
		this.warehouseService = warehouseService;
	}
	
	public void setDepartmentsService(DepartmentsService departmentsService)
	{
		this.departmentsService = departmentsService;
	}
	//物料进销存报表
	
	
	//车间领料统计表
	@RequestMapping("/getOutMaterial")
	public ModelAndView getOutMaterial(HttpServletRequest request,HttpServletResponse response, @RequestParam(value="page", defaultValue="1")int page){
		int pageSize = 10;
		MyRequest req = new MyRequest(request);
		Map map = req.getParameterValueMap(false, true);
		//map.xml配置文件中对应的SQL命名空间
		String namespaceId = "getOutMaterial";
		PageModel<Warehouse> pageModel = warehouseService.getPage(page, pageSize, map,namespaceId);
		ModelAndView result = new ModelAndView();
		PageNav pageNav = new PageNav(request, pageModel);
		List departList = departmentsService.getList(new HashMap());//部门信息
		result.addObject("departList", departList);
		result.addObject("pageModel", pageModel);
		result.addObject("pageNav", pageNav);
		result.setViewName("/manage/report/warehouse/getOutMaterial.jsp");
		return result;
	}
	
	
	
	//调拨汇总表
	@RequestMapping("/getGoodsTrac")
	public ModelAndView getGoodsTrac(HttpServletRequest request,HttpServletResponse response, @RequestParam(value="page", defaultValue="1")int page){
		int pageSize = 10;
		MyRequest req = new MyRequest(request);
		Map map = req.getParameterValueMap(false, true);
		//map.xml配置文件中对应的SQL命名空间
		String namespaceId = "getGoodsTrac";
		PageModel<Warehouse> pageModel = warehouseService.getPage(page, pageSize, map,namespaceId);
		ModelAndView result = new ModelAndView();
		PageNav pageNav = new PageNav(request, pageModel);
		List departList = departmentsService.getList(new HashMap());//部门信息
		result.addObject("departList", departList);
		result.addObject("pageModel", pageModel);
		result.addObject("pageNav", pageNav);
		result.setViewName("/manage/report/warehouse/getGoodsTrac.jsp");
		return result;
	}
	
	
	//盘盈盘亏表
	@RequestMapping("/getLossMaterial")
	public ModelAndView getLossMaterial(HttpServletRequest request,HttpServletResponse response, @RequestParam(value="page", defaultValue="1")int page){
		int pageSize = 10;
		MyRequest req = new MyRequest(request);
		Map map = req.getParameterValueMap(false, true);
		//map.xml配置文件中对应的SQL命名空间
		String namespaceId = "getLossMaterial";
		PageModel<Warehouse> pageModel = warehouseService.getPage(page, pageSize, map,namespaceId);
		ModelAndView result = new ModelAndView();
		PageNav pageNav = new PageNav(request, pageModel);
		//List departList = departmentsService.getList(new HashMap());//部门信息
		//result.addObject("departList", departList);
		result.addObject("pageModel", pageModel);
		result.addObject("pageNav", pageNav);
		result.setViewName("/manage/report/warehouse/getLossMaterial.jsp");
		return result;
	}

}
